home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / util / archie.1 < prev    next >
Text File  |  1989-03-15  |  9KB  |  343 lines

  1. Path: xanth!lll-winken!ames!mailrus!ulowell!page
  2. From: page@swan.ulowell.edu (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i054:  archie - arexx scripts for directory management
  5. Message-ID: <12236@swan.ulowell.edu>
  6. Date: 15 Mar 89 18:26:58 GMT
  7. Organization: University of Lowell, Computer Science Dept.
  8. Lines: 332
  9. Approved: page@swan.ulowell.edu
  10.  
  11. Submitted-by: CB%frambo.DEC@decwrl.dec.com  (Christian Balzer)
  12. Posting-number: Volume 89, Issue 54
  13. Archive-name: util/archie.1
  14.  
  15. Archie.rexx will copy all files that don't have the archive bit set
  16. from SOURCE and it's subdirectories to DESTINATION. If these
  17. directories don't exist at DESTINATION, Archie will try to create them
  18. on the fly and thus preserving the original structure at SOURCE.
  19. After the file has been copied, it's archive bit will be set.
  20.  
  21. Equalize.rexx is a utility for Archie and will scan all files at
  22. SOURCE and it's subdirectories and compare them to the files at
  23. DESTINATION and the corresponding subdirectories. ALL files at
  24. DESTINATION that can't be found in SOURCE will be DELETED!!!  This
  25. goes for directory trees, too!!!
  26.  
  27. System requirements:
  28. Any Amiga model, 512 KB, ARexx.
  29. Especially useful for people with more than one hard disk or other
  30. mass storage devices. I call Archie every 2 hours from AmiCron and
  31. Equalize once a week to keep a backup of valuable data from my large
  32. HD on my smaller one.
  33.  
  34. #    This is a shell archive.
  35. #    Remove everything above and including the cut line.
  36. #    Then run the rest of the file through sh.
  37. #----cut here-----cut here-----cut here-----cut here----#
  38. #!/bin/sh
  39. # shar:    Shell Archiver
  40. #    Run the following text with /bin/sh to create:
  41. #    Archie.rexx
  42. #    Equalize.rexx
  43. # This archive created: Wed Mar 15 13:22:18 1989
  44. cat << \SHAR_EOF > Archie.rexx
  45. /* Archie.rexx -- a backup utility by <CB> aka Christian Balzer
  46.    based on du.rexx by Larry Phillips.
  47.     _  _
  48.  / /  | \ \  <CB> aka Christian Balzer  - The Software Brewery -
  49. < <   |-<  > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com
  50.  \ \_ |_/ /  CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!)
  51. ------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G.
  52.  
  53. Usage: [rx] Archie SOURCE DESTINATION [-options]
  54.  
  55. SOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing
  56. slashes '/'.
  57. Valid options are: Currently none...
  58.  
  59. Archie will copy all files that don't have the archive bit set
  60. from SOURCE and it's subdirectories to DESTINATION. If these
  61. directories don't exist at DESTINATION, Archie will try to create
  62. them on the fly and thus preserving the original structure at SOURCE.
  63. After the file has been copied, it's archive bit will be set.
  64.  
  65. Note: The files will be copied with 'CLONE' flag of the COPY command
  66. set. This of course only works with the 1.3 version of COPY. 
  67. In this version of Archie, filenames or directories containing blanks
  68. (like "My Dir:My File"), are NOT supported!  */
  69.  
  70. /* This is Public Domain, read the source and learn */
  71.  
  72. say 'Archie 1.6 (12-Jan-89) by <CB>'
  73.  
  74. /* open the Rexx support library */
  75.  
  76. if ~show('L',"rexxsupport.library") then do
  77.    if addlib('rexxsupport.library',0,-30,0) then
  78.       say 'added rexxsupport.library'
  79.    else do;
  80.       say 'support library not available'
  81.       exit 10
  82.       end
  83.    end
  84.  
  85. address command
  86. call pragma 'priority',-1
  87.  
  88. arg rein
  89.  
  90. /* The parser */ 
  91. copt = 'clone'
  92.  
  93. if words(rein) < 2 then do
  94.     say 'Come on, gimme a SOURCE *AND* a DESTINATION path'
  95.     say 'Ya better try again... Bye!'
  96.     exit 10
  97. end
  98.  
  99.  
  100. root = subword(rein,1,1)
  101. dest = subword(rein,2,1)
  102.  
  103. if ~ exists(root) then do
  104.     say 'Source not found'
  105.     say 'Exiting... Check your parameters'
  106.     exit 10
  107. end 
  108.  
  109. if ~ exists(dest) then do
  110.     say 'Destination not found'
  111.     say 'I''ll try to create it for you...'
  112.     'makedir 'dest
  113.     if ~ exists(dest) then do
  114.         say 'Exiting... Check your parameters'
  115.         exit 15
  116.     end
  117.     say 'Created 'dest
  118. end 
  119.  
  120. if right(root,1) ~= ':' then
  121.   root = root || '/'
  122. if root = '/' then root = ''
  123.  
  124. if right(dest,1) ~= ':' then
  125.   dest = dest || '/'
  126. if dest = '/' then dest = ''
  127.  
  128. rlen = length(root)
  129.  
  130. bytes = 0
  131. blocks = 0
  132. files = 0
  133. dircount = 1
  134.  
  135. say 'Archie is doing it''s job on 'root
  136.  
  137. call dolist(root)
  138.  
  139. say
  140. say 'Archived:' bytes 'bytes,' blocks 'blocks, ',
  141.      files 'files in a total 'dircount' directories.'
  142. exit 0
  143.  .
  144.  
  145. /* The real thing */
  146.  
  147. dolist: procedure expose bytes blocks files dest rlen dircount copt
  148. parse arg x
  149. contents = showdir(x);
  150. do i = 1 to words(contents)
  151.   temp = x || word(contents,i)
  152.   flen = length(word(contents,i))
  153.   type = statef(temp)
  154.   if word(type,1) = 'FILE' then
  155.     do
  156.       if substr(word(type,4),4,1) = '-' then
  157.         do
  158.         target = dest || right(temp,(length(temp) - rlen))
  159.         'copy 'temp target copt
  160. /*        if RC > 0 then
  161.           say 'Error archiving 'temp
  162.         else */
  163.         do
  164.           files = files + 1
  165.           bytes = bytes + word(type,2)
  166.           blocks = blocks + word(type,3) + 1
  167.           'protect 'temp 'a add'
  168. /*          if RC > 0 then
  169.             say 'Error protecting 'temp
  170.           else */
  171.           say 'Archived: 'temp
  172.         end  
  173.     end
  174.     end
  175.   if word(type,1) ='DIR' then do
  176.     subdir = dest || right(temp,(length(temp) - rlen))
  177.     if ~ exists(subdir) then
  178.       do
  179.         'makedir' subdir
  180.         if ~ exists(subdir) then do
  181.           say 'Sorry... Exiting'
  182.           exit 20
  183.         end
  184.         say ' *** Created directory' subdir
  185.       end
  186.     call dolist(temp || '/')
  187.     dircount = dircount + 1
  188.   end
  189. end
  190. return
  191. SHAR_EOF
  192. cat << \SHAR_EOF > Equalize.rexx
  193. /* equalize.rexx -- a utility for Archie by Christian '<CB>' Balzer
  194.  
  195. --  _  _
  196.  / /  | \ \  <CB> aka Christian Balzer  - The Software Brewery -
  197. < <   |-<  > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com
  198.  \ \_ |_/ /  CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!)
  199. ------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G.
  200.  
  201. Usage: [rx] equalize SOURCE DESTINATION [-options]
  202.  
  203. SOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing
  204. slashes '/'.
  205. Valid options are: -p    This option will only print the differing
  206.             filenames, but not delete them. Use it to
  207.             see if you aren't about to destroy your work!
  208.  
  209. Equalize will scan all files at SOURCE and it's subdirectories and
  210. compare them to the files at DESTINATION and the corresponding
  211. subdirectories. ALL files at DESTINATION that can't be found in
  212. SOURCE will be DELETED!!! This goes for directory trees, too!!!
  213.  
  214. WARNING!!! Use this beast only when you know what you're doing! :-)
  215.  
  216. BTW, the name of this utility wasn't inspired by the TV series 
  217. "The Equalizer". Or was it? :-)
  218.  
  219. In this version, filenames or directories containing blanks
  220. (like "My Dir:My File"), are NOT supported!  */
  221.  
  222. /* This is Public Domain, read the source and learn */
  223.  
  224. say 'Equalize 1.2 (13-Jan-88) by <CB>'
  225.  
  226. /* open the Rexx support library */
  227.  
  228. if ~show('L',"rexxsupport.library") then do
  229.    if addlib('rexxsupport.library',0,-30,0) then
  230.       say 'added rexxsupport.library'
  231.    else do;
  232.       say 'support library not available'
  233.       exit 10
  234.       end
  235.    end
  236.  
  237. address command
  238. call pragma 'priority',-1
  239.  
  240. arg rein
  241.  
  242. /* The parser */ 
  243. copt = 'clone'
  244.  
  245. if words(rein) < 2 then do
  246.     say 'Come on, gimme a SOURCE *AND* a DESTINATION path'
  247.     say 'Ya better try again... Bye!'
  248.     exit 10
  249. end
  250.  
  251.  
  252. root = subword(rein,1,1)
  253. dest = subword(rein,2,1)
  254. dstat = 1
  255.  
  256. if ~ exists(root) then do
  257.     say 'Source not found'
  258.     say 'Exiting... Check your parameters'
  259.     exit 10
  260. end 
  261.  
  262. if ~ exists(dest) then do
  263.     say 'Destination not found'
  264.     say 'Exiting... Check your parameters'
  265.     exit 15
  266. end
  267.  
  268. if words(rein) > 2 then do
  269.     if subword(rein,3,1) = '-P' then
  270.         dstat = 0
  271. end
  272.  
  273. if right(root,1) ~= ':' then
  274.   root = root || '/'
  275. if root = '/' then root = ''
  276.  
  277. if right(dest,1) ~= ':' then
  278.   dest = dest || '/'
  279. if dest = '/' then dest = ''
  280.  
  281. dlen = length(dest)
  282.  
  283. bytes = 0
  284. files = 0
  285. dircount = 1
  286.  
  287. say 'Equalize is doing it''s job on 'dest
  288.  
  289. call dolist(dest)
  290.  
  291. say
  292. say 'Deleted:' files 'files in a total 'dircount' directories.'
  293. say 'This equalization cleared:' bytes 'Bytes.'
  294. exit 0
  295.  
  296.  
  297. /* The real thing */
  298.  
  299. dolist: procedure expose files root dest dlen dircount bytes dstat
  300. parse arg x
  301. contents = showdir(x);
  302. do i = 1 to words(contents)
  303.   temp = x || word(contents,i)
  304.   type = statef(temp)
  305.   if word(type,1) = 'FILE' then
  306.     do
  307.     snam = root || right(temp,(length(temp) - dlen))
  308.     if ~ exists(snam) then
  309.     do
  310.         files = files + 1
  311.         bytes = bytes + word(type,2)
  312.         if dstat = 1 then 
  313.         do
  314.             'delete 'temp            
  315.             say 'Deleted: 'temp
  316.         end
  317.         else say 'Would have deleted: 'temp
  318.     end
  319.     end
  320.   if word(type,1) ='DIR' then do
  321.     subdir = root || right(temp,(length(temp) - dlen))
  322.     if ~ exists(subdir) then
  323.       do
  324.           say 'Subdirectory 'subdir' not found...'
  325.         if dstat = 1 then 
  326.         do
  327.             'delete 'temp' all'            
  328.             say 'Removed: 'temp
  329.         end
  330.         else say 'Would have removed: 'temp
  331.       end
  332.     call dolist(temp || '/')
  333.     dircount = dircount + 1
  334.   end
  335. end
  336. return
  337. SHAR_EOF
  338. #    End of shell archive
  339. exit 0
  340. -- 
  341. Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
  342. Have five nice days.
  343.